package com.kingwang.training.ooad.coffeemaker.goodway;

/**
 * 用户操作界面
 *
 * @author King
 */
public abstract class UserInterface {
    private HotWaterSource hotWaterSource;
    private ContainmentVessel containmentVessel;

    protected boolean completed;

    public UserInterface() {
        this.completed = true;
    }

    public void init(HotWaterSource hotWaterSource, ContainmentVessel containmentVessel) {
        this.hotWaterSource = hotWaterSource;
        this.containmentVessel = containmentVessel;
    }

    public void complete() {
        this.completed = true;
        completeCycle();
    }

    protected void startBrewing() {
        if (this.hotWaterSource.isReady() && this.containmentVessel.isReady()) {
            this.completed = false;
            this.hotWaterSource.start();
            this.containmentVessel.start();
        }
    }

    public abstract void done();

    public abstract void completeCycle();
}
